/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.edu.itschapala.sistemas.septimo.vista;

import javax.swing.JFrame;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnArchivo;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnLocal;
import mx.edu.itschapala.sistemas.septimo.control.ProductoLNLocal;
import mx.edu.itschapala.sistemas.septimo.control.ProductoLnArchivo;
import mx.edu.itschapala.sistemas.septimo.control.VentaLnArchivo;
import mx.edu.itschapala.sistemas.septimo.control.VentaLnLocal;
import mx.edu.itschapala.sistemas.septimo.vista.enumeracion.TipoVentana;

/**
 *
 * @author Ingenieriaz
 */
public class StartMenu extends javax.swing.JFrame {
    
    private JFrame listar,listarC;//variable para administrar ventana
    /**
     * Creates new form StartMenu
     */
    public StartMenu() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        mRegistrar = new javax.swing.JMenuItem();
        mbuscar = new javax.swing.JMenuItem();
        mListar = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        mClRegistrar = new javax.swing.JMenuItem();
        mClBuscar = new javax.swing.JMenuItem();
        mClListar = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMeRegistro = new javax.swing.JMenuItem();
        jMeBuscar = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setLocationByPlatform(true);
        setResizable(false);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mx/edu/itschapala/sistemas/septimo/imgs/11245.jpg"))); // NOI18N

        jPanel1.setOpaque(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 252, Short.MAX_VALUE)
        );

        jMenuBar1.setBackground(new java.awt.Color(255, 255, 255));
        jMenuBar1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jMenu1.setText("Producto");

        mRegistrar.setText("Registrar");
        mRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mRegistrarActionPerformed(evt);
            }
        });
        jMenu1.add(mRegistrar);

        mbuscar.setText("Buscar");
        mbuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mbuscarActionPerformed(evt);
            }
        });
        jMenu1.add(mbuscar);

        mListar.setText("Listar");
        mListar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mListarActionPerformed(evt);
            }
        });
        jMenu1.add(mListar);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Cliente");

        mClRegistrar.setText("Registrar");
        mClRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mClRegistrarActionPerformed(evt);
            }
        });
        jMenu2.add(mClRegistrar);

        mClBuscar.setText("Buscar");
        mClBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mClBuscarActionPerformed(evt);
            }
        });
        jMenu2.add(mClBuscar);

        mClListar.setText("Listar");
        mClListar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mClListarActionPerformed(evt);
            }
        });
        jMenu2.add(mClListar);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Venta");

        jMeRegistro.setText("Registrar");
        jMeRegistro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMeRegistroActionPerformed(evt);
            }
        });
        jMenu3.add(jMeRegistro);

        jMeBuscar.setText("Buscar");
        jMeBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMeBuscarActionPerformed(evt);
            }
        });
        jMenu3.add(jMeBuscar);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private final ProductoLNLocal productoControl=new ProductoLnArchivo();
    private final ClienteLnLocal clienteControl=new ClienteLnArchivo();
    private final VentaLnLocal ventaControl=new VentaLnArchivo();
    
    private void mRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mRegistrarActionPerformed
        new Registrar(null,productoControl,TipoVentana.VENTANA_REGISTRO).setVisible(true);
    }//GEN-LAST:event_mRegistrarActionPerformed

    private void mbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mbuscarActionPerformed
       new Registrar(null,productoControl,TipoVentana.VENTANA_BUSCAR).setVisible(true);
    }//GEN-LAST:event_mbuscarActionPerformed

    private void mListarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mListarActionPerformed
        if(listar==null){
          listar=new ProductoListar(productoControl);
        
        }
        listar.setVisible(true);
    }//GEN-LAST:event_mListarActionPerformed

    private void mClRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mClRegistrarActionPerformed
        
        new RegistrarC(null,clienteControl,TipoVentana.VENTANA_REGISTRO).setVisible(true);
    }//GEN-LAST:event_mClRegistrarActionPerformed

    private void mClListarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mClListarActionPerformed
        if(listarC==null){
          listarC=new ClienteListar(clienteControl);
        
        }
        listarC.setVisible(true);
    }//GEN-LAST:event_mClListarActionPerformed

    private void mClBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mClBuscarActionPerformed
          new RegistrarC(null,clienteControl,TipoVentana.VENTANA_BUSCAR).setVisible(true);
    }//GEN-LAST:event_mClBuscarActionPerformed

    private void jMeRegistroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMeRegistroActionPerformed
        new RegistrarV(clienteControl, productoControl, TipoVentana.VENTANA_REGISTRO, ventaControl).setVisible(true);
    }//GEN-LAST:event_jMeRegistroActionPerformed

    private void jMeBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMeBuscarActionPerformed
        new RegistrarV(clienteControl, productoControl, TipoVentana.VENTANA_BUSCAR, ventaControl).setVisible(true);
    }//GEN-LAST:event_jMeBuscarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(StartMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(StartMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(StartMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(StartMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new StartMenu().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuItem jMeBuscar;
    private javax.swing.JMenuItem jMeRegistro;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JMenuItem mClBuscar;
    private javax.swing.JMenuItem mClListar;
    private javax.swing.JMenuItem mClRegistrar;
    private javax.swing.JMenuItem mListar;
    private javax.swing.JMenuItem mRegistrar;
    private javax.swing.JMenuItem mbuscar;
    // End of variables declaration//GEN-END:variables
}
